package cn.xyinping.order.controller;

import cn.xyinping.basic.exception.MyException;
import cn.xyinping.basic.util.AjaxResult;
import cn.xyinping.order.domain.OrderPet;
import cn.xyinping.order.dto.OrderDto;
import cn.xyinping.order.service.IOrderPetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 27266
 * @desrciption 宠物订单
 * @date 2021/11/7
 */
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private IOrderPetService orderPetService;
    // 保存订单
    @PostMapping("/save")
    public AjaxResult saveOrder(@RequestBody OrderDto dto) {
        try {
            String orderNo = orderPetService.saveOrder(dto);
            System.out.println("111111111");
            System.out.println(orderNo);
            return AjaxResult.me().setResultObj(orderNo);
        } catch (MyException e) {
            e.printStackTrace();
            return AjaxResult.me().setMessage(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.me().setMessage("系统繁忙");
        }
    }
}
